package com.atguigu.tingshu.account.service;

import com.atguigu.tingshu.model.account.UserAccount;
import com.atguigu.tingshu.model.account.UserAccountDetail;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;

public interface UserAccountService extends IService<UserAccount> {


    /**
     * 初始化账户接口
     * @param userId
     */
    void initUserAccount(String userId);

    /**
     * 获取账号可用金额接口
     * @param userId
     * @return
     */
    BigDecimal getAvailableAmount(Long userId);

    /**
     * 检查与锁定账户金额接口
     * @param accountLockVo
     * @return
     */
    AccountLockResultVo checkAndLock(AccountLockVo accountLockVo);

    /**
     * 扣除锁定金额
     * @param orderNo
     */
    void minus(String orderNo);

    /**
     * 解除锁定金额
     * @param orderNo
     */
    void unlock(String orderNo);

    /**
     * 更新余额
     * @param userId
     * @param amount
     * @param orderNo
     * @param tradeType
     * @param title
     */
    void add(Long userId, BigDecimal amount, String orderNo, String tradeType, String title) ;

    /**
     * 获取用户充值记录接口
     * @param pageParam
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserRechargePage(Page<UserAccountDetail> pageParam, Long userId);

    /**
     * 获取用户消费记录接口
     * @param pageParam
     * @param userId
     * @return
     */
    IPage<UserAccountDetail> findUserConsumePage(Page<UserAccountDetail> pageParam, Long userId);

    /**
     * 检查及扣减账户余额接口
     * @param accountDeductVo
     */
    void checkAndDeduct(AccountLockVo accountDeductVo);
}
